#!/bin/bash
nginxurl=/opt/openresty/nginx
. $nginxurl/scripts/golo.conf
byip=192.168.8.151
if [ ! -f "$RTK_WS_PATH/rtk-odom-ether/config/init_coord_map.yaml" ];then
  sudo cp $RTK_WS_PATH/rtk-odom-ether/config/init_coord.yaml  $RTK_WS_PATH/rtk-odom-ether/config/init_coord_map.yaml
fi
sudo sed -i 's/real_monitor.py/real_monitor_v3.py/g' $GOLO_WS_PATH/golo/websocket-client/launch/monitor.launch
rtkodom_init=$( cat /etc/ros/melodic/goloR.d/rtkodom.launch |grep rtk_odom|wc -l )
if [ $rtkodom_init -eq 1 ];then
sudo sed -i 's/init_coord.yaml/init_coord_map.yaml/g' /opt/ros/melodic/share/rtk_odom/launch/rtkodom.launch
else
sudo sed -i 's/init_coord.yaml/init_coord_map.yaml/g' /opt/ros/melodic/share/jz_driver/launch/unicore.launch
fi
websockv3=$( cat $GOLO_WS_PATH/golo/websocket-client/launch/monitor.launch grep real_monitor_v3 |wc -l)
if [ $websockv3 -eq 0 ];then
	sudo sed -i 's/real_monitor.py/real_monitor_v3.py/g' $GOLO_WS_PATH/golo/websocket-client/launch/monitor.launch
fi
if [  -f "$GOLO_WS_PATH/golo/websocket-client/scripts/real_monitor.py" ];then
sudo systemctl restart goloWM 
fi
sudo systemctl restart goloR ; sudo systemctl restart  goloW3 ; sudo systemctl stop goloW ; echo y |rosnode cleanup 
